import pymysql

'''
查询
'''
def query(sql):
    db = pymysql.connect('127.0.0.1','root','root','tx_logger',charset='utf8')
    cur = db.cursor()
    try:
        cur.execute(sql)
        result = cur.fetchall()
        db.commit()
        # print('query success')
    except:
        db.rollback()
    cur.close()
    db.close()
    return result
